﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/3/20 23:55:00
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;
using ueEngine.Biz.Inf.Entities.DBSupport;

namespace ueEngine.Biz.Inf.LogicEntity
{
    public class CorporationModel : IAccessible<Corporation,CorporationModel>
    {
        #region self
        /// <summary>
        /// 商家Id
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 代理人。对应Member中用户名
        /// </summary>
        public string Agent { get; set; }

        /// <summary>
        /// 商家名
        /// </summary>
        public string CompanyName { get; set; }

        /// <summary>
        /// 关于商家
        /// </summary>
        public string About { get; set; }

        /// <summary>
        /// 公司地址
        /// </summary>
        public string Location { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 联系邮箱
        /// </summary>
        public string EMail { get; set; }

        ///// <summary>
        ///// 是否是官方认证商家
        ///// </summary>
        //public bool Identification { get; set; }

        ///// <summary>
        ///// 审核材料Id
        ///// </summary>
        //public int CertificationId { get; set; }

        /// <summary>
        /// 企业认证级别
        /// </summary>
        public CertificationLevel CertificationLevel { get; set; }
        #endregion

        #region agent
        public MemberModel AgentInfo { get; set; }
        #endregion

        protected override void Covariant(Corporation dbCorporation)
        {
            this.About = dbCorporation.About;
            this.Agent = dbCorporation.Agent;
            this.CompanyName = dbCorporation.CompanyName;
            this.EMail = dbCorporation.EMail;
            this.Id = dbCorporation.Id;
            //this.Identification = dbCorporation.Identification;
            this.Location = dbCorporation.Location;
            this.Phone = dbCorporation.Phone;
            //this.CertificationId = dbCorporation.CertificationId;
            this.CertificationLevel = (CertificationLevel)dbCorporation.CertificationLevel;
        }
        protected override Corporation Inverter(CorporationModel model)
        {
            var dbCorporation = new Corporation()
            {
                About = model.About,
                CompanyName = model.CompanyName,
                Agent = model.Agent,
                EMail = model.EMail,
                Id = model.Id,
                //Identification = model.Identification,
                Location = model.Location,
                Phone = model.Phone,
                //CertificationId = model.CertificationId
                CertificationLevel =(int)model.CertificationLevel
            };
            return dbCorporation;
        }
        //public override CorporationModel Element(System.Linq.Expressions.Expression<Func<Corporation, bool>> where)
        //{
        //    Covariant(new Corporation().Get(where));
        //    return this;
        //}
        //public override List<TResult> Elements<TResult>(System.Linq.Expressions.Expression<Func<Corporation, bool>> where, System.Linq.Expressions.Expression<Func<Corporation, TResult>> select)
        //{
        //    using (Context ctx = new Context())
        //    {
        //        return ctx.Corporation.Where(where).Select(select).ToList();
        //    }
        //}
    }
}
